#!/bin/sh
######################
#
# It's nesseray that to run convert_SMW_to_return before this module 
#
######################
FOLDER=caculate_return


mv *.array.top50 ${FOLDER}
mv *.month.return ${FOLDER}
cd ${FOLDER}

# generate caculate_return.sh
echo "#!/bin/sh" > ${FOLDER}.sh
cat all.array.top50 >> ${FOLDER}.sh
echo "for file in 1_50 1_150 1_200 2_200 5_150 10_200
do
##" >> ${FOLDER}.sh 

filenames=`wc -l all.array.top50 | awk '{print $1}'`
#####
echo "i=0
while [ \$i -le $((filenames-1)) ]" >> ${FOLDER}.sh
#####
cat ${FOLDER}.tample.1.sh >> ${FOLDER}.sh

chmod a+x *.sh
./${FOLDER}.sh

